package cn.edu.zafu.bigdata.zqt.studentsystem.service.impl;

import cn.edu.zafu.bigdata.zqt.studentsystem.entity.Student;
import cn.edu.zafu.bigdata.zqt.studentsystem.service.AbstractService;
import cn.edu.zafu.bigdata.zqt.studentsystem.utils.FileUtils;
import cn.edu.zafu.bigdata.zqt.studentsystem.utils.InputUtils;

/**
 * 修改学生信息
 *
 * @author zqt
 */
public class UpdateStudent extends AbstractService {

    /**
     * 读取用户输入
     */
    @Override
    protected void handleUserInput() {
        Student student = InputUtils.findStudentById();
        if (student != null) {
            String name = InputUtils.readName();
            String phone = InputUtils.readPhone();
            student.setName(name);
            student.setPhone(phone);
            if (InputUtils.confirm()) {
                FileUtils.updateData();
                System.out.println("数据更新成功");
            }
        }
    }
}
